<div ng-controller="attachmentCtrl" style="display: table;width: 100%">
    <div style="width:140px;display: table-cell;">
        <!--style="overflow-y: auto;overflow-x: hidden"-->
        <div  id="folderScroll">
            <ul >
                <li ng-repeat="type in typeList" style="position: relative">
                    <form novalidate name="form">
                        <button ng-show="!type.edit" ng-click="selectType(type)" class="btn btn-default nameBtn" ng-class="{'active':type.active}" >{{type.text}}</button>
                        <input ng-show="type.edit" uib-tooltip="{{!type.textCopy?'不可为空':(form.textCopy.$invalid?'有重名':null)}}"
                               ensure-unique="iconType"
                               type="text" ng-model="type.textCopy" name="textCopy" class="form-control" required style="margin-bottom: 5px;"/>
                        <div class="absDiv hoverShow" ng-show="!type.edit" ng-if="$root.hasPower('编辑附件')">
                            <button  class="btn btn-default roundBtn" ng-click="editType(type)" title="编辑"><i class="glyphicon glyphicon-pencil"></i></button>
                            <button  class="btn btn-danger roundBtn" ng-click="delType(type)" title="删除"><i class="glyphicon glyphicon-remove"></i></button>
                        </div>
                        <div class="absDiv" ng-show="type.edit">
                            <button  class="btn btn-primary roundBtn" ng-click="saveType(form,type)" title="保存"><i class="glyphicon glyphicon-ok"></i></button>
                            <button  class="btn btn-default roundBtn" ng-click="cancelEdit(type)" title="撤消"><i class="fa fa-undo"></i></button>
                        </div>
                    </form>
                </li>
                <li class="text-center"  ng-if="$root.hasPower('编辑附件')">
                    <button class="btn btn-primary roundBtn" ng-click="typeList.push({edit:true})"><i class="glyphicon glyphicon-plus"></i></button>
                </li>
            </ul>
        </div>
    </div>
    <div style="padding-left: 15px" ng-style="{visibility:curType?'visible':'hidden'}">
        <div class="x_panel" >
            <div class="form-inline">
                <div class="form-group">
                    <label>名称 </label>
                    <input type="text" ng-model="search.name"  class="form-control" />
                </div>
                <button class="btn btn-primary" ng-click="find(1)" >查询</button>
                <button class="btn btn-default" ng-click="search.name=''" >重置</button>

                <button class="btn btn-primary pull-right"  ng-if="$root.hasPower('编辑附件')" ng-click="addFiles({'folderId':curType.id})" >添加</button>
                <button class="btn btn-danger pull-right mr5"  ng-if="$root.hasPower('编辑附件')" ng-disabled="!hasChecked(pageModel.data)" ng-click="delAll()">批量删除</button>
                <button class="btn btn-default pull-right mr5"  ng-if="$root.hasPower('下载附件')" ng-disabled="!hasChecked(pageModel.data)" ng-click="downloadZip()">下载</button>
            </div>
        </div>

        <table class="table table-bordered table-striped table-hover" >
            <thead class="title">
            <tr>
                <th class="text-center">NO</th>
                <th th-check items="pageModel.data" class="text-center" style="width:20px"></th>
                <th>名称</th>
                <th>大小</th>
                <th>创建人</th>
                <th>创建时间</th>
                <th style="width:120px" ng-if="$root.hasPower('编辑附件')">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-if="pageModel.data.length == 0">
                <td colspan="100" class="text-center">暂无记录</td>
            </tr>
            <tr ng-repeat="item in pageModel.data">
                <td class="text-center">{{$index + 1+pageModel.pageSize*pageModel.pageIndex}}</td>
                <td td-check item="item"></td>
                <td><a href="{{item.path}}" download="{{item.name}}" class="btn-link">{{item.name}}</a></td>
                <td>{{item.size>0?(item.size+"KB"):""}}</td>
                <td>{{item.creatorName}}</td>
                <td>{{item.createTime| date:'yyyy-MM-dd HH:mm:ss'}}</td>
                <td ng-if="$root.hasPower('编辑附件')">
                    <a href='javascript:void(0)' ng-click='del(item)' class='btn btn-xs btn-link'><span class='fa fa-trash'></span>删除</a>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
<style>
    .nameBtn{
        width: 140px;
        margin-bottom: 5px;
        position: relative;
        white-space:normal;
        word-break: break-word;
    }
    .absDiv{
        position: absolute;
        top: 5px;
        right: 8px;
        z-index: 2;
        right: -50px;
    }
    .hoverShow{
        display: none;
    }
    li:hover .hoverShow{
        display: block;
    }
    .roundBtn {
        padding: 4px;
        border-radius: 15px;
        line-height: 14px;
    }
    .nameBtn.active{
        box-shadow: inset 0 3px 5px rgba(0,0,0,.5)
    }
</style>